package com.codeyn.base.result;

public class PageResult<T> extends ListResult<T> {
    private static final long serialVersionUID = 8974290576116307803L;

    private int pageNo;
    private int pageSize;
    private int totalRow;
    private int totalPage;

    public int getPageNo() {
        return pageNo;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalRow() {
        return totalRow;
    }

    public void setTotalRow(int totalRow) {
        this.totalRow = totalRow;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    @Override
    public String toString() {
        final int maxLen = 10;
        StringBuilder builder = new StringBuilder();
        builder.append("PageResult [isSuccess=").append(isSuccess).append(", code=").append(code).append(", message=")
                .append(message).append(", dataList=")
                .append(dataList != null ? dataList.subList(0, Math.min(dataList.size(), maxLen)) : null)
                .append(", totalRow=").append(totalRow).append(", totalPage=").append(totalPage).append(", pageNo=")
                .append(pageNo).append(", pageSize=").append(pageSize).append("]");
        return builder.toString();
    }

}
